package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Warehouse;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class WarehouseVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主id")
    private Integer id;

    @ApiModelProperty(value = "仓库名称")
    private String name;

    @ApiModelProperty(value = "公司id")
    private Integer companyId;

    @ApiModelProperty(value = "仓库负责人")
    private Integer adminId;

    @ApiModelProperty(value = "仓库地址")
    private String address;

    @ApiModelProperty(value = "仓库紧急联系电话")
    private String phone;

    @ApiModelProperty(value = "是否临时：0，是临时仓库，1：永久仓库")
    private Integer isTemporary;

    @ApiModelProperty(value = "是否启用：0禁用，1启用")
    private Integer state;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "是否在盘点：0否 1是")
    private Integer isInventory;

    @ApiModelProperty(value = "仓库负责人名称")
    private String adminName;



    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Warehouse convert(WarehouseVO vo) {
        Warehouse entity = new Warehouse();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Warehouse> convertList(List<WarehouseVO> list) {
        List<Warehouse> resultList = new ArrayList<>();
        for (WarehouseVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
